package com.hyt.it.ogt.data.service.pj.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hyt.core.base.BaseServiceImpl;
import com.hyt.core.util.UUIDUtils;
import com.hyt.it.ogt.data.mapper.pj.PjDataStudentAnswerMapper;
import com.hyt.it.ogt.data.model.entity.pj.StudentAnswer;
import com.hyt.it.ogt.data.model.vo.pj.StudentAnswerVO;
import com.hyt.it.ogt.data.service.pj.IPjDataStudentAnswerService;

/**
 * <p>
 * 考生作答表 服务实现类
 * </p>
 *
 * @author liuqi
 * @date 2022-06-07
 */
@Service
public class PjDataStudentAnswerServiceImpl extends BaseServiceImpl<PjDataStudentAnswerMapper, StudentAnswer> implements IPjDataStudentAnswerService {
	
	@Resource
	private PjDataStudentAnswerMapper pjDataStudentAnswerMapper;


    @Override
    public void saveStudentAnswer(String projectId, List<StudentAnswerVO> studentAnswerVOs) {
        List<StudentAnswer> studentAnswers = new ArrayList<>();
        for(StudentAnswerVO studentAnswerVO: studentAnswerVOs){
            StudentAnswer studentAnswer = new StudentAnswer();
            studentAnswer.setId(UUIDUtils.newSortUUID());
            studentAnswer.setProjectId(studentAnswerVO.getProjectId());
            studentAnswer.setSubjectId(studentAnswerVO.getSubjectId());
            studentAnswer.setItemId(studentAnswerVO.getItemId());
            studentAnswer.setAdmissionNum(studentAnswerVO.getAdmissionNumber());
            studentAnswer.setAnswer(studentAnswerVO.getSubjectiveAnswer());
            studentAnswers.add(studentAnswer);
        }
        this.saveBatch(studentAnswers);
    }

}
